<template>
	<view class="fui-wrap">
		<fui-list>
			<fui-list-cell v-for="(item,index) in list" :key="index">
				<view class="item">
					<view class="line">
						<fui-text text="车位编号：" color="#afafaf" :size="28" align="right"></fui-text>
						<fui-text :text="item.code" color="#000" :size="28" align="right"></fui-text>
					</view>
					<view class="line">
						<fui-text text="车位状态：" color="#afafaf" :size="28" align="right"></fui-text>
						<fui-text v-if="item.records_id" text="占用" color="red" :size="28" align="right"></fui-text>
						<fui-text v-else text="空闲" color="red" :size="28" align="right"></fui-text>
					</view>
					<view class="line">
						<fui-text text="车牌号：" color="#afafaf" :size="28" align="right"></fui-text>
						<fui-text :text="item.plate_number" color="#000" :size="28" align="right"></fui-text>
					</view>
					<view class="line">
						<fui-text text="车辆入场时间：" color="#afafaf" :size="28" align="right"></fui-text>
						<fui-text :text="item.records.entry_time_txt" color="#000" :size="28" align="right"></fui-text>
					</view>
					<view class="line">
						<fui-text text="占用车位时间：" color="#afafaf" :size="28" align="right"></fui-text>
						<fui-text :text="item.entry_time" color="#000" :size="28" align="right"></fui-text>
					</view>
					<view class="line">
						<fui-text text="临停时长：" color="#afafaf" :size="28" align="right"></fui-text>
						<fui-text v-if="item.provisional>5*60" :text="parseInt(item.provisional/60)+'分钟'" color="red" :size="28" align="right"></fui-text>
						<fui-text v-else text="不存在" color="green" :size="28" align="right"></fui-text>
					</view>
				</view>
			</fui-list-cell>
		</fui-list>
		<fui-empty v-if="list.length===0" :src="`${baseUrl}assets/img/miniapp/empty.png`" title="暂无数据!" :marginTop="200"></fui-empty>
	</view>
</template>

<script>
	import {methods,baseUrl} from '@/utils/core.js';
	import platetype from '@/components/common/platetype.vue';
	export default {
		components:{
			platetype:platetype
		},
		data() {
			return {
				baseUrl:baseUrl,
				cars_id:'',
				list:[]
			}
		},
		onLoad(e) {
			this.cars_id=e.cars_id;
			this.getList();
		},
		onPullDownRefresh() {
			this.list=[];
			this.getList(function(){
				uni.stopPullDownRefresh();
			});
		},
		methods: {
			...methods,
			getList:function(callback=false){
				this.$get('parking/cars/occupat',{cars_id:this.cars_id},true).then(res=>{
					this.list=res;
					if(callback){
						callback();
					}
				});
			}
		}
	}
</script>

<style lang="scss" scoped>
.item{
	display: flex;
	justify-content: space-between;
	width: 100%;
	flex-wrap: wrap;
	.line{
		line-height: 50rpx;
	}
}
</style>